/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ua.ad.feedsreader.actions;

import com.opensymphony.xwork2.ActionSupport;
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.apache.struts2.interceptor.SessionAware;
import ua.ad.feedsreader.mybatis.config.MyBatisSqlSessionFactory;
import ua.ad.feedsreader.mybatis.mappers.beans.Utilizador;
import ua.ad.feedsreader.mybatis.mappers.clients.UserCategoriaPalavraMapper;

/**
 *
 * @author sexta13
 */
public class RemoverPalavraChaveCategoriaAction extends ActionSupport implements SessionAware{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2673054437996804604L;
	private Map<String, Object> session;
	private int idCategoria;
	private int idPalavraChave;


	@Override
	public String execute() throws Exception { 

		Utilizador userSession = (Utilizador) getSession().get("utilizador");

		SqlSession bdSession = MyBatisSqlSessionFactory.getSqlSessionFactory().openSession();

		UserCategoriaPalavraMapper ucpMapper = bdSession.getMapper(UserCategoriaPalavraMapper.class);
		ucpMapper.deleteByUserCategoriaPalavra(userSession.getId(),getIdCategoria(), getIdPalavraChave());

		bdSession.close();

		return SUCCESS;

	}
	
	public Map<String, Object> getSession() {
		return session;
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public int getIdCategoria() {
		return idCategoria;
	}

	public void setIdCategoria(int idCategoria) {
		this.idCategoria = idCategoria;
	}

	public int getIdPalavraChave() {
		return idPalavraChave;
	}

	public void setIdPalavraChave(int idPalavraChave) {
		this.idPalavraChave = idPalavraChave;
	}


}
